package com.alan.product.issue.exception;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@Slf4j
@ControllerAdvice
public class GlobalExceptionHandler {

    @ResponseBody
    @ExceptionHandler
    public String paramErrorException(ParamErrorException e) {
        log.error("catch param error exception", e);
        return "fail:400";
    }

    @ResponseBody
    @ExceptionHandler
    public String serverErrorException(ServerErrorException e) {
        log.error("catch server error exception", e);
        return "fail:500";
    }

    @ResponseBody
    @ExceptionHandler
    public String exception(Exception e) {
        log.error("catch unknown exception", e);
        return "fail:500";
    }
}
